package cn.kgc.ffzw.myeat.services.impl;

import cn.kgc.ffzw.myeat.commons.Collection;
import cn.kgc.ffzw.myeat.module.Users;
import cn.kgc.ffzw.myeat.services.LoginService;

/**
 * @author
 * @Des
 * @date 2019/11/26
 */
public abstract class AbstractUser extends Users implements LoginService {
    public AbstractUser() {
    }

    public AbstractUser(int userId, String realName
            , String account, String password, int age
            , int sex, String telephone, String address, String power) {
        super(userId, realName, account, password, age, sex, telephone, address, power);

    }

    @Override
    public Users login(Collection users, String username, String password) {
        Users user = null;
        for(int i=0;i<users.size();i++){
            Users us = (Users)users.get(i);
            if(us.getAccount().equals(username)
                    && us.getPassword().equals(password)) {
                user = us;
                break;
            }
        }
        return user;
    }
}
